package restful;

import java.util.*;

public class RestfulTopic {

	private String name;

	private List<RestfulResource> resources = new LinkedList<RestfulResource>();

	public RestfulTopic() {}

	public RestfulTopic(String name) {
		this.name = name;
	}

	public RestfulTopic addResource(RestfulResource resource) {
		resource.setTopic(this);
		resources.add(resource);
		return this;
	}

	@Override
	public boolean equals(Object obj) {
		if(obj instanceof RestfulTopic) {
			RestfulTopic topic = (RestfulTopic) obj;
			return name.equals(topic.name);
		}
		return false;
	}

	public String getName() {
		return name;
	}

	public List<RestfulResource> getResources() {
		return resources;
	}

	@Override
	public int hashCode() {
		return name.hashCode();
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public String toString() {
		return name;
	}
}
